﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Web.Models;
using Web.Models.Helpers;
using Wombat.Data.Model;

namespace Web.Controllers
{
    public class MonitoringController : Controller
    {
        //
        // GET: /Monitoring/

        public ActionResult Index()
        {
            using (var db = new WombatEntities())
            {
                var model =
                    db.Tags
                    .Include("Unit")
                    .Select(
                        t => new TagDto { Id = t.Id, Guid = t.Guid, Name = t.Name, Unit = t.Unit.Name, UnitId = t.Unit.Id })
                        .ToList();
                return View(model);
            }
        }

        public ActionResult Graph(long id)
        {
            using (var db = new WombatEntities())
            {
                var tag = TagHelper.GetTagById(db, (int)id);
                return View(new TagDto { Id = tag.Id, Guid = tag.Guid, Name = tag.Name });
            }
        }

        public ActionResult Ufo()
        {
            using (var db = new WombatEntities())
            {
                ViewBag.Ufo_latId = TagHelper.GetTagById(db, 27).Guid.ToString();
                ViewBag.Ufo_lngId = TagHelper.GetTagById(db, 28).Guid.ToString();
                ViewBag.Ufo_power = TagHelper.GetTagById(db, 29).Guid.ToString();
                ViewBag.Ufo_signalRecievedPower = TagHelper.GetTagById(db, 30).Guid.ToString();
            }
            return View();
        }
    }
}
